﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace MikeProject003_Console.MyClasses
{
    class TestDouble
    {
        
        static public  void MainTest()
        {

            int v_i;
            double v_d =new double();
            

            



            for (v_i = 1; v_i < 100; v_i++) 
            {
                v_d = v_d + 0.1;
                Console.WriteLine(v_d);
            }

            Console.ReadLine();
            



        }
    }

    class Based
    {
        public int i = new Int32();

        public  int ii
        {
            get
            {
                System.Windows.Forms.MessageBox.Show("Считано");
                return i;
                
            }

            set
            {
                i = i + value;
                System.Windows.Forms.MessageBox.Show("Установлено");
            }
        }
    }

    class MyInherited : Based
    {
        public int y=7;

        public int FTtest(ref Int32 Minp, out Int32 Mout)
        {

            Mout = Minp + 1;

            return 8;

        }

 
        /* Тестирую params */
        public void test001(int iz, params int[] mas)
        {
            int hack;
            hack = iz;
            
            Console.WriteLine(i);
            iz = hack + 33; ;

            

            foreach (int submas in mas)
            {
                Console.WriteLine(submas);
            }




        }

        public void test002(MyClasses.Based Tested, string s)
        {
            Console.WriteLine(Tested.i);

            Tested.i = 22;
            s = "Changed";

            Console.WriteLine(Tested.i);


        }

        //Факториал, рекурсия
        public int test003(int n)
        {
            if (n<=1) return 1;
            else return n * test003(n-1);
        }

        //Массивы
        public void test004_Array()
        {
            int i;
            i = 0;

            string[] Arr = { "A", "B", "C" };
            /*
            while (i <= Arr.GetLength(0) - 1)
            {
                Arr[i] = new int[Arr.Length + i];

                i = i + 1;

                
            }
            */

            object[] oobbbjjj = new object[3];
            oobbbjjj = Arr;
            
            this.test004_Interface_Array(oobbbjjj);

            try
            {
                i = Arr.GetLength(1);
            }
            catch
            {
                i = Arr.GetLength(0);
            }

         

        }

        //Передача в ИНТЕРФЕЙС!!! array
        public void test004_Interface_Array(Object[] RealObj)
        {

            foreach (object item in RealObj)
            {
                Console.WriteLine("\t {0}", item.ToString());
            }

        }

        public void test005_CharAndString()
        {
            int i;
            char c;
            
            c = new char();
            c = Convert.ToChar("ё");

            string s = "new";
            string s_001 = "001";
            StringBuilder sb_osn = new StringBuilder("stb");
            StringBuilder sb_001 = new StringBuilder("stb");

            sb_001 = sb_osn;
            s_001 = s;
            s = "str";

            sb_osn[1] = 'e';
            
            c = s[0];

           

            Console.WriteLine("sb_osn.Capacity = {0}, sb_osn.MaxCapacity = {1}", sb_osn.Capacity, sb_osn.MaxCapacity);


            
        }

        public void test006_PersonAndChildren()
        {
            MyClasses.Classes_001_Person Pers_Childr001 = new Classes_001_Person();
            Pers_Childr001.age = 10;
            Pers_Childr001.salary = -7000;

            MyClasses.Classes_001_Person Pers_adult = new Classes_001_Person();
            Pers_adult.age = 30;
            Pers_adult.salary = 1200000000;

            Pers_adult[000] = Pers_Childr001;

            MyClasses.Classes_001_Person[] Pers_adult_arr = new Classes_001_Person[10];
            Pers_adult_arr[0] = Pers_adult;

          

            
        }

        public void test007_Class_as_array()
        {

            MyClasses.Classes_002_Array_in_class NewClass = new Classes_002_Array_in_class();

            NewClass.fill();
            NewClass[3] = 166;
  

            Console.WriteLine(NewClass[3]);



        }

        public void test08_Operator()
        {
            MyClasses.Classes_003_MyOperator My001 = new Classes_003_MyOperator();
            MyClasses.Classes_003_MyOperator My002 = new Classes_003_MyOperator();
            MyClasses.Classes_003_MyOperator My003 = new Classes_003_MyOperator();

            Classes_003_MyOperator ret;
            My001.i = 4;
            My002.i = 3;
            My003.i = 3;
            
            ret = My001 + My002 +My003;


        }

        delegate void test10_delegate();

        public void test09_delegate()
        {
            
            test10_delegate test10_delegate001 = new test10_delegate(MyClasses.classes_004_event_delegate.FTestDel);

            test10_delegate001 += new test10_delegate(MyClasses.classes_004_event_delegate.FTestDelBest);

            test10_delegate001();
            



        }

        public void test10_event()
        {
            MyClasses.classes_005_event classes_005_event_001 = new MyClasses.classes_005_event();
            MyClasses.classes_006_event_add Test = new MyClasses.classes_006_event_add(classes_005_event_001);


            classes_005_event_001.OnEvent_in_town("aa");

            
            

        }

        public void test11_arraylist()
        {
            
            ArrayList  MyArrayList = new ArrayList();

            MyArrayList.Add(5);

            MyArrayList.Add("g");

            foreach (object subarr in MyArrayList)
            {
                Console.WriteLine(subarr);



            } 

        }

        public void test12_Handler_event()
        {
            
            MyClasses.classes_007_event_arr _my1 = new classes_007_event_arr();
            _my1.Add(777);
            MyClasses.classes_008_Receiver1 _my2 = new classes_008_Receiver1(_my1);

            do
            {
                _my1[0] = Convert.ToInt32(Console.ReadLine());
            }
            while (Convert.ToInt32( _my1[0]) != 888);
            


            

        }

        public void test12_template()
        {
            int i = 5;
            int y = 7;
            MyClasses.classes_009_Template<System.Int32>.swap(ref i, ref y);

        }

        public void test13_template_stack()
        {
            MyClasses.classes_012_stack_elems<int> Stack1 = new classes_012_stack_elems<int>();

            Stack1.Put(5);

            Stack1.Put(7);

            Stack1.Put(15);
            while (true)
            {
                try
                {

                    Console.WriteLine(Stack1.getitem());
                    Stack1.Remove();
                }
                catch
                {
                    return;
                }

            }
        }

        public void test14_conditional()
        {
            int i, y,zero;

            zero = 0;
            MyClasses.classes_013_DebugPrint.PrintEntry("ABC");

            System.Diagnostics.Trace.Assert(false, "Перебор");

            try
            {
                i = 5;
                y = i / zero;
            }
            catch(Exception e)
            {
                y = 2;

            }

            finally
            {
                zero = 7;
            }


        }

    }

    
}
